home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / QuickDraw GX / QuickDraw GX Info / QuickDraw GX Interfaces / Interfaces & Libraries / Pascal Interfaces & Libraries / Pascal Interfaces / Collections.p next >
Encoding:
Text File  |  1994-03-24  |  12.0 KB  |  429 lines  |  [TEXT/MPS ]

  1. { ------------------------------------------------------------------------------
  2.  
  3.     FILENAME
  4.         Collections.p
  5.  
  6.     DESCRIPTION
  7.         This file contains all of the public data structures, constants, and 
  8.         function declarations for the Collection Manager.
  9.  
  10.     COPYRIGHT
  11.         Copyright © Apple Computer, Inc. 1989, 1990, 1991, 1992, 1993
  12.         All rights reserved. 
  13.  
  14. ------------------------------------------------------------------------------- }
  15.  
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.     UNIT Collections;
  23.     INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED UsingCollections}
  27. {$SETC UsingCollections := 1}
  28.  
  29. {$I+}
  30. {$SETC CollectionsIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32. {$IFC UNDEFINED UsingTypes}
  33. {$I $$Shell(PInterfaces)Types.p}
  34. {$ENDC}
  35. {$SETC UsingIncludes := CollectionsIncludes}
  36.  
  37. { Constants }
  38.  
  39.  
  40. CONST
  41. { Collection Manager Gestalt Selector... }
  42.  
  43.     gestaltCollectionMgrVersion = 'cltn';
  44.  
  45. { Collection Manager Error Result Codes... }
  46.  
  47.     collectionItemLockedErr = -5750;
  48.     collectionItemNotFoundErr = -5751;
  49.     collectionIndexRangeErr = -5752;
  50.     collectionVersionErr = -5753;
  51.  
  52.  
  53. { Convenience constants for calls to functions which optionally return values... }
  54.  
  55.     dontWantTag = 0;
  56.     dontWantId = 0;
  57.     dontWantSize = 0;
  58.     dontWantAttributes = 0;
  59.     dontWantIndex = 0;
  60.     dontWantData = 0;
  61.  
  62.  
  63. { attributes bits }
  64.  
  65.     noCollectionAttributes = $00000000;            { no attributes bits set }
  66.     allCollectionAttributes = $FFFFFFFF;        { all attributes bits set }
  67.     userCollectionAttributes = $0000FFFF;        { user attributes bits }
  68.     defaultCollectionAttributes = $40000000;    { default attributes - unlocked, persistent }
  69.  
  70.  
  71.     Attribute bits 0 through 15 (entire low word) are reserved for use by the application.
  72.     Attribute bits 16 through 31 (entire high word) are reserved for use by the Collection Manager.
  73.     Only bits 31 (collectionLockBit) and 30 (collectionPersistenceBit) currently have meaning.
  74. }
  75.  
  76.  
  77.     collectionUser0Bit            = 0;
  78.     collectionUser1Bit            = 1;
  79.     collectionUser2Bit            = 2;
  80.     collectionUser3Bit            = 3;
  81.     collectionUser4Bit            = 4;
  82.     collectionUser5Bit            = 5;
  83.     collectionUser6Bit            = 6;
  84.     collectionUser7Bit            = 7;
  85.     collectionUser8Bit            = 8;
  86.     collectionUser9Bit            = 9;
  87.     collectionUser10Bit            = 10;
  88.     collectionUser11Bit            = 11;
  89.     collectionUser12Bit            = 12;
  90.     collectionUser13Bit            = 13;
  91.     collectionUser14Bit            = 14;
  92.     collectionUser15Bit            = 15;
  93.     
  94.     collectionReserved0Bit        = 16;
  95.     collectionReserved1Bit        = 17;
  96.     collectionReserved2Bit        = 18;
  97.     collectionReserved3Bit        = 19;
  98.     collectionReserved4Bit        = 20;
  99.     collectionReserved5Bit        = 21;
  100.     collectionReserved6Bit        = 22;
  101.     collectionReserved7Bit        = 23;
  102.     collectionReserved8Bit        = 24;
  103.     collectionReserved9Bit        = 25;
  104.     collectionReserved10Bit        = 26;
  105.     collectionReserved11Bit        = 27;
  106.     collectionReserved12Bit        = 28;
  107.     collectionReserved13Bit        = 29;
  108.     
  109.     collectionPersistenceBit    = 30;
  110.     collectionLockBit                = 31;
  111.  
  112.  
  113. { attribute masks }
  114.  
  115.     collectionUser0Mask            = $00000001;
  116.     collectionUser1Mask            = $00000002;
  117.     collectionUser2Mask            = $00000004;
  118.     collectionUser3Mask            = $00000008;
  119.     collectionUser4Mask            = $00000010;
  120.     collectionUser5Mask            = $00000020;
  121.     collectionUser6Mask            = $00000040;
  122.     collectionUser7Mask            = $00000080;
  123.     collectionUser8Mask            = $00000100;
  124.     collectionUser9Mask            = $00000200;
  125.     collectionUser10Mask            = $00000400;
  126.     collectionUser11Mask            = $00000800;
  127.     collectionUser12Mask            = $00001000;
  128.     collectionUser13Mask            = $00002000;
  129.     collectionUser14Mask            = $00004000;
  130.     collectionUser15Mask            = $00008000;
  131.  
  132.     collectionReserved0Mask            = $00010000;
  133.     collectionReserved1Mask            = $00020000;
  134.     collectionReserved2Mask            = $00040000;
  135.     collectionReserved3Mask            = $00080000;
  136.     collectionReserved4Mask            = $00100000;
  137.     collectionReserved5Mask            = $00200000;
  138.     collectionReserved6Mask            = $00400000;
  139.     collectionReserved7Mask            = $00800000;
  140.     collectionReserved8Mask            = $01000000;
  141.     collectionReserved9Mask            = $02000000;
  142.     collectionReserved10Mask        = $04000000;
  143.     collectionReserved11Mask        = $08000000;
  144.     collectionReserved12Mask        = $10000000;
  145.     collectionReserved13Mask        = $20000000;
  146.     collectionReserved14Mask        = $40000000;
  147.     collectionReserved15Mask        = $80000000;
  148.  
  149.     collectionPersistenceMask    = $40000000;        { mask for lock bit }
  150.     collectionLockMask            = $80000000;        { mask for lock bit }
  151.  
  152.  
  153. { the Collection Manager trap }
  154.  
  155.     collectionManagerTrap = $ABF6;
  156.  
  157.  
  158. { Types }
  159.  
  160.  
  161. TYPE
  162.  
  163.     PrivateCollectionRecord = LONGINT;
  164.     Collection = ^PrivateCollectionRecord;    { abstract data type for a collection }
  165.     CollectionTag = LONGINT;                    { collection member 4 byte tag }
  166.     CollectionTagPtr = ^CollectionTag;
  167.     CollectionFlattenProc = ProcPtr;
  168.     CollectionExceptionProc = ProcPtr;
  169.  
  170.  
  171. {
  172.     A CollectionFlattenProc should look like this:
  173.  
  174.     FUNCTION MyFlattenProc (size : LONGINT; data : UNIV Ptr; refCon : UNIV Ptr) : OSErr;
  175. }
  176.  
  177.  
  178. {
  179.     A CollectionExceptionProc should look like this:
  180.  
  181.     FUNCTION MyExceptionProc (aCollection : Collection; anErr : OSErr) : OSErr;
  182. }
  183.  
  184.  
  185. {*********************************************************************}
  186. { ***************            Public Interfaces            **********************}
  187. { ********************************************************************}
  188.  
  189.  
  190. FUNCTION NewCollection : Collection;
  191.     INLINE $7000,collectionManagerTrap;
  192.  
  193. PROCEDURE DisposeCollection (aCollection : Collection);
  194.     INLINE $7001,collectionManagerTrap;
  195.  
  196. FUNCTION CloneCollection (aCollection : Collection) : Collection;
  197.     INLINE $7002,collectionManagerTrap;
  198.  
  199. FUNCTION CountCollectionOwners (aCollection : Collection) : LONGINT;
  200.     INLINE $7003,collectionManagerTrap;
  201.  
  202. FUNCTION CopyCollection (srcCollection, dstCollection : Collection) : Collection;
  203.     INLINE $7004,collectionManagerTrap;
  204.  
  205. FUNCTION GetCollectionDefaultAttributes (aCollection : Collection) : LONGINT;
  206.     INLINE $7005,collectionManagerTrap;
  207.  
  208. PROCEDURE SetCollectionDefaultAttributes (aCollection : Collection;
  209.                                                         whichAttributes: LONGINT;
  210.                                                           newAttributes : LONGINT);
  211.     INLINE $7006,collectionManagerTrap;
  212.  
  213.  
  214. FUNCTION CountCollectionItems (aCollection : Collection) : LONGINT;
  215.     INLINE $7007,collectionManagerTrap;
  216.  
  217.  
  218. FUNCTION AddCollectionItem (aCollection : Collection;
  219.                                        tag : CollectionTag;
  220.                                       id : LONGINT;
  221.                                       itemSize : LONGINT;
  222.                                       pItemData : UNIV Ptr) : OSErr;
  223.     INLINE $7008,collectionManagerTrap;
  224.  
  225.  
  226. FUNCTION GetCollectionItem (aCollection : Collection;
  227.                                         tag : CollectionTag;
  228.                                         id : LONGINT;
  229.                                         pItemSize : LongIntPtr;
  230.                                         pItemData : UNIV Ptr) : OSErr;
  231.     INLINE $7009,collectionManagerTrap;
  232.  
  233.  
  234. FUNCTION RemoveCollectionItem (aCollection : Collection;
  235.                                          tag : CollectionTag;
  236.                                          id: LONGINT) : OSErr;
  237.     INLINE $700A,collectionManagerTrap;
  238.  
  239.  
  240. FUNCTION SetCollectionItemInfo (aCollection : Collection;
  241.                                              tag : CollectionTag;
  242.                                             id : LONGINT;
  243.                                               whichAttributes : LONGINT;
  244.                                             newAttributes : LONGINT) : OSErr;
  245.     INLINE $700B,collectionManagerTrap;
  246.  
  247.  
  248. FUNCTION GetCollectionItemInfo (aCollection : Collection;
  249.                                              tag : CollectionTag;
  250.                                             id : LONGINT;
  251.                                               pIndex : LongIntPtr;
  252.                                             pItemSize : LongIntPtr;
  253.                                               pAttributes : LongIntPtr) : OSErr;
  254.     INLINE $700C,collectionManagerTrap;
  255.  
  256.  
  257. FUNCTION ReplaceIndexedCollectionItem (aCollection : Collection;
  258.                                                            index : LONGINT;
  259.                                                         itemSize : LONGINT;
  260.                                                        pItemData : UNIV Ptr) : OSErr;
  261.     INLINE $700D,collectionManagerTrap;
  262.  
  263.  
  264. FUNCTION GetIndexedCollectionItem (aCollection : Collection;
  265.                                                   index : LONGINT;
  266.                                                  pItemSize : LongIntPtr;
  267.                                                 pItemData : UNIV Ptr) : OSErr;
  268.     INLINE $700E,collectionManagerTrap;
  269.  
  270.  
  271.  
  272. FUNCTION RemoveIndexedCollectionItem (aCollection : Collection;
  273.                                                   index : LONGINT) : OSErr;
  274.     INLINE $700F,collectionManagerTrap;
  275.  
  276.  
  277. FUNCTION SetIndexedCollectionItemInfo (aCollection : Collection;
  278.                                                         index : LONGINT;
  279.                                                         whichAttributes : LONGINT;
  280.                                                      newAttributes : LONGINT) : OSErr;
  281.     INLINE $7010,collectionManagerTrap;
  282.  
  283.  
  284. FUNCTION GetIndexedCollectionItemInfo (aCollection : Collection;
  285.                                                   index : LONGINT;
  286.                                                  pTag : CollectionTagPtr;
  287.                                                  pId : LongIntPtr;
  288.                                                   pItemSize : LongIntPtr;
  289.                                                  pAttributes : LongIntPtr) : OSErr;
  290.     INLINE $7011,collectionManagerTrap;
  291.  
  292.  
  293. FUNCTION CollectionTagExists (aCollection : Collection;
  294.                                         tag : CollectionTag) : Boolean;
  295.     INLINE $7012,collectionManagerTrap;
  296.  
  297.  
  298. FUNCTION CountCollectionTags (aCollection : Collection) : LONGINT;
  299.     INLINE $7013,collectionManagerTrap;
  300.  
  301.  
  302. FUNCTION GetIndexedCollectionTag (aCollection : Collection;
  303.                                              whichTag : LONGINT;
  304.                                              var tag : CollectionTag) : OSErr;
  305.     INLINE $7014,collectionManagerTrap;
  306.  
  307.  
  308. FUNCTION CountTaggedCollectionItems (aCollection : Collection;
  309.                                                  tag : CollectionTag) : LONGINT;
  310.     INLINE $7015,collectionManagerTrap;
  311.  
  312.  
  313. FUNCTION GetTaggedCollectionItem (aCollection : Collection;
  314.                                              tag : CollectionTag;
  315.                                              whichItem : LONGINT;
  316.                                              pItemSize : LongIntPtr;
  317.                                              pItemData : UNIV Ptr) : OSErr;
  318.     INLINE $7016,collectionManagerTrap;
  319.  
  320.  
  321. FUNCTION GetTaggedCollectionItemInfo (aCollection : Collection;
  322.                                                    tag : CollectionTag;
  323.                                                    whichItem : LONGINT;
  324.                                                   pID : LongIntPtr;
  325.                                                   pIndex : LongIntPtr;
  326.                                                    pItemSize : LongIntPtr;
  327.                                                    pAttributes : LongIntPtr) : OSErr;
  328.     INLINE $7017,collectionManagerTrap;
  329.  
  330.  
  331. PROCEDURE PurgeCollection (aCollection : Collection;
  332.                                     whichAttributes : LONGINT;
  333.                                     matchingAttributes : LONGINT);
  334.     INLINE $7018,collectionManagerTrap;
  335.  
  336.  
  337. PROCEDURE PurgeCollectionTag (aCollection : Collection;
  338.                                         tag : CollectionTag);
  339.     INLINE $7019,collectionManagerTrap;
  340.  
  341.  
  342. PROCEDURE EmptyCollection (aCollection : Collection);
  343.     INLINE $701A,collectionManagerTrap;
  344.  
  345.  
  346. FUNCTION FlattenCollection (aCollection : Collection;
  347.                                      flattenProc : CollectionFlattenProc;
  348.                                      refCon : UNIV Ptr) : OSErr;
  349.     INLINE $701B,collectionManagerTrap;
  350.  
  351.  
  352. FUNCTION FlattenPartialCollection (aCollection : Collection;
  353.                                                flattenProc : CollectionFlattenProc;
  354.                                                refCon : UNIV Ptr;
  355.                                               whichAttributes : LONGINT;
  356.                                               matchingAttributes : LONGINT) : OSErr;
  357.     INLINE $701C,collectionManagerTrap;
  358.  
  359.  
  360. FUNCTION UnflattenCollection (aCollection : Collection;
  361.                                         flattenProc: CollectionFlattenProc;
  362.                                         refCon : UNIV Ptr) : OSErr;
  363.     INLINE $701D,collectionManagerTrap;
  364.  
  365.  
  366. FUNCTION GetCollectionExceptionProc (aCollection : Collection) : CollectionExceptionProc;
  367.     INLINE $701E,collectionManagerTrap;
  368.  
  369.  
  370. PROCEDURE SetCollectionExceptionProc (aCollection : Collection;
  371.                                                   exceptionProc : CollectionExceptionProc);
  372.     INLINE $701F,collectionManagerTrap;
  373.  
  374.  
  375.  
  376. {**************************************************************************************}
  377. { Utility Routines for handle-based access...                                                        }
  378. {**************************************************************************************}
  379.  
  380.  
  381.  
  382. FUNCTION GetNewCollection (collectionID : INTEGER) : Collection;
  383.     INLINE $7020,collectionManagerTrap;
  384.  
  385.  
  386. FUNCTION AddCollectionItemHdl (aCollection : Collection;
  387.                                               tag : CollectionTag;
  388.                                               id : LONGINT;
  389.                                               hItemData : Handle) : OSErr;
  390.     INLINE $7021,collectionManagerTrap;
  391.  
  392.  
  393. FUNCTION GetCollectionItemHdl (aCollection : Collection;
  394.                                             tag : CollectionTag;
  395.                                             id : LONGINT;
  396.                                               hItemData : Handle) : OSErr;
  397.     INLINE $7022,collectionManagerTrap;
  398.  
  399.                           
  400. FUNCTION ReplaceIndexedCollectionItemHdl (aCollection : Collection;
  401.                                                                 index : LONGINT;
  402.                                                             hItemData : Handle) : OSErr;
  403.     INLINE $7023,collectionManagerTrap;
  404.  
  405.                                     
  406. FUNCTION GetIndexedCollectionItemHdl (aCollection : Collection;
  407.                                                        index : LONGINT;
  408.                                                         hItemData : Handle) : OSErr;
  409.     INLINE $7024,collectionManagerTrap;
  410.  
  411.                           
  412. FUNCTION FlattenCollectionToHdl (aCollection : Collection;
  413.                                             flattened : Handle) : OSErr;
  414.     INLINE $7025,collectionManagerTrap;
  415.  
  416.  
  417. FUNCTION UnflattenCollectionFromHdl (aCollection : Collection;
  418.                                                  flattened : Handle) : OSErr;
  419.     INLINE $7026,collectionManagerTrap;
  420.  
  421.  
  422.  
  423. {$ENDC}    { UsingCollections }
  424.  
  425. {$IFC NOT UsingIncludes}
  426.     END.
  427. {$ENDC}
  428.